package com.xbb.utils

import java.util.Date

import org.apache.commons.lang3.time.FastDateFormat

object DateUtil {
  def main(args: Array[String]): Unit = {
    println(parseToMinute("2017-04-01 14:46:20"))
  }

  private val source: FastDateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss")
  private val target: FastDateFormat = FastDateFormat.getInstance("yyyyMMddHHmmss")

  def getTime(time: String): Long = {
    source.parse(time).getTime
  }

  def parseToMinute(time: String): String = {
    target.format(new Date(getTime(time)))
  }
}
